﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Utility.Events;

namespace TimeTracker.EditForms
{
    public partial class EditSession : Form
    {
        protected ISession Session
        {
            get;
            set;
        }

        public EditSession(ISession session)
        {
            this.Session = session;

            InitializeComponent();

            this.session1.StartDate = this.Session.StartTime;
            this.session1.EndDate = this.Session.EndTime;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            this.Session.StartTime = this.session1.StartDate;
            this.Session.EndTime = this.session1.EndDate;

            Manager.Instance.Save();

            this.Saved.Fire(sender, this.Session);

            this.Close();
        }

        public event EventHandler<EventArgs<ISession>> Saved;
    }
}
